﻿using System.Windows;

namespace ServiceLayerManagement
{
    public class MessageHelper
    {
        public static void Info(string msg)
        {
            MessageBox.Show(msg, "提示", MessageBoxButton.OK, MessageBoxImage.Information);
        }
        public static void Info(Window owner, string msg)
        {
            AppHelper.RunInUI(owner, () =>
            {
                MessageBox.Show(owner, msg, "提示", MessageBoxButton.OK, MessageBoxImage.Information);
            });
        }

        public static void Error(string msg)
        {
            MessageBox.Show(msg, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
        }
        public static void Error(Window owner, string msg)
        {
            AppHelper.RunInUI(owner, () =>
            {
                MessageBox.Show(owner, msg, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
            });
        }

        public static bool Question(string msg)
        {
            if (MessageBox.Show(msg, "询问", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
                return true;
            else
                return false;
        }
        public static bool Question(Window owner, string msg)
        {
            bool result = false;
            AppHelper.RunInUI(owner, () =>
            {
                if (MessageBox.Show(owner, msg, "询问", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
                    result = true;
            });
            return result;
        }


        public static void Warn(string text)
        {
            MessageBox.Show(text, "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
        }
        public static void Warn(string text, string caption)
        {
            MessageBox.Show(text, caption, MessageBoxButton.OK, MessageBoxImage.Warning);
        }
        public static void Warn(Window owner, string text)
        {
            AppHelper.RunInUI(owner, () =>
            {
                MessageBox.Show(owner, text, "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
            });
        }
    }
}
